package com.qf.ex;

import com.qf.util.Result;
import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author sunyamei
 * @version V1.0
 * @Project shirodemo
 * @Package com.qf.ex
 * @Description:
 * @Date 2022/7/20 19:43
 */
@RestControllerAdvice
public class MyHandlerException {

    @ExceptionHandler({
            CustomException.class
    })
    public Result handlerCustomException(CustomException e){
        e.printStackTrace();
        return  Result.error(e.getMessage());
    }
    @ExceptionHandler({
            UnauthorizedException.class
    })
    public  Result handlerUnauthorizedException(UnauthorizedException e){
        e.printStackTrace();
        return  new Result(401,"权限不足");
    }
    @ExceptionHandler({
            Exception.class
    })
    public  Result handlerOtherException(Exception e){
        e.printStackTrace();
        return  Result.error("系统异常,请联系管理员");
    }
}
